package org.example.timertask;

import io.netty.util.HashedWheelTimer;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

import java.util.List;

public class TimerTaskStartRunner implements ApplicationRunner {

    private final HashedWheelTimer hashedWheelTimer;
    private final ThreadPoolTaskExecutor taskExecutor;
    private final List<BaseTimerTaskStartConfiguration> configurations;
    public TimerTaskStartRunner(HashedWheelTimer hashedWheelTimer,
                                ThreadPoolTaskExecutor taskExecutor,
                                List<BaseTimerTaskStartConfiguration> configurations) {
        this.hashedWheelTimer = hashedWheelTimer;
        this.taskExecutor = taskExecutor;
        this.configurations = configurations;
    }

    @Override
    public void run(ApplicationArguments args) {
        configurations.forEach(item->item.startConfig(hashedWheelTimer,taskExecutor));
    }

}
